home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 November / Chip Kasım 2000.iso / prog / share / 11 / setup.exe / %MAINDIR% / DEMOS / CIFTP / FTPEXP / callback.cls < prev    next >
Encoding:
Text File  |  2000-09-07  |  4.6 KB  |  117 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "FTPCallback"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = False
  8. Option Explicit
  9.  
  10. '----------------------------------------------------
  11. '<Purpose> callback function that is used to show the
  12. ' FTPServer files and directories in the ListView
  13. '----------------------------------------------------
  14. Public Function ListFTPItems(ThisSession As Form, ThisExplorer As Form, ServerNode As Node)
  15.     Dim IsDir           As Boolean
  16.     Dim InstanceFile    As CIFTPLib.File
  17.     Dim i               As Integer
  18.     Dim ListCount       As Integer
  19.     Dim TheseItems      As ListItems
  20.     Dim WorkingItem     As ListItem
  21.     Dim TheseNodes      As Nodes
  22.     Dim WorkingNode     As Node
  23.     Dim DirKey          As String
  24.     Dim FormattedSize   As String
  25.     Dim FullPathName    As String
  26.     Dim ItemKey         As String
  27.     Dim ListItem        As String
  28.     Dim NodeKey         As String
  29.     Dim ServerKey       As String
  30.     Dim WorkingDir      As String
  31.     
  32.     '----- cache data
  33.     ServerKey = ServerNode.Key
  34.     WorkingDir = ThisSession.WorkingDir
  35.     
  36.     '---- cache explorer objects
  37.     Set TheseNodes = ThisExplorer.Tree.Nodes
  38.     Set TheseItems = ThisExplorer.List.ListItems
  39.     
  40.     On Error GoTo BadFile
  41.     
  42.     '---- add all files and create extra data for each
  43.     DirKey = ThisSession.ciSession.WorkingDirectory & "/"
  44.     For Each InstanceFile In ThisSession.ciSession.Files
  45.         ListItem = InstanceFile.FileName
  46.         If (ListItem <> "") Then
  47.             IsDir = (InstanceFile.Attributes And FTP_ATTRIB_DIRECTORY)
  48.         
  49.             If IsDir Then
  50.                 If ((ListItem <> ".") And (ListItem <> "..")) Then
  51.                 
  52.                     '---- concatenate the full path
  53.                     If (WorkingDir = "/") Then
  54.                         FullPathName = "/" & ListItem
  55.                     Else
  56.                         FullPathName = WorkingDir & "/" & ListItem
  57.                     End If
  58.                     
  59.                     NodeKey = ServerKey & "." & ListItem
  60.                     
  61.                     If (Not IsKeyed(TheseNodes, NodeKey)) Then
  62.                         Set WorkingNode = TheseNodes.Add(ServerNode, tvwChild, NodeKey, ListItem, imgFolderClosed, imgFolderOpen)
  63.                         
  64.                         '---- add extra data
  65.                         Dim ThisAttachment As New Attachment
  66.                         ThisAttachment.NodeType = nodFTPFolder
  67.                         ThisAttachment.DrivePath = FullPathName
  68.                         Set ThisAttachment.Session = ThisSession
  69.                         Call ThisExplorer.Attachments.Add(ThisAttachment, NodeKey)
  70.                         Set ThisAttachment = Nothing
  71.                         
  72.                         '---- add searching placeholder
  73.                         Call TheseNodes.Add(WorkingNode, tvwChild, WorkingNode.Key & nodPlaceHolder, nodPlaceHolder, imgPlaceHolder)
  74.                     End If
  75.                     
  76.                     '---- add directory to ListView; pad with invisible char for sorting purposes
  77.                     Set WorkingItem = TheseItems.Add(, NodeKey, Chr(160) & ListItem, imgFolderClosed, imgFolderClosed)
  78.                     '---  add type, size, and modified bits to item
  79.                     'WorkingItem.SubItems(1) = Str(FileLen(FullPathName) \ 1024) & "KB"
  80.                     WorkingItem.SubItems(2) = "FTP File Folder"
  81.                     'WorkingItem.SubItems(3) = Format(FileDateTime(FullPathName), "General Date")
  82.                 End If
  83.             Else
  84.                 ItemKey = DirKey & ListItem
  85.             
  86.                 '---- add directory to ListView; pad with invisible char for sorting purposes
  87.                 Set WorkingItem = TheseItems.Add(, ItemKey, ListItem, imgFTPFile, imgFTPFile)
  88.                 WorkingItem.Tag = ServerNode.Key
  89.         
  90.                 '---  add type, size, and modified bits to item
  91.                 FormattedSize = Str((InstanceFile.FileSize \ 1024) + 1) & "KB"
  92.                 'If (FormattedSize = " 0KB") Then FormattedSize = " 1KB"
  93.                 WorkingItem.SubItems(1) = FormattedSize
  94.                 WorkingItem.SubItems(2) = "FTP File"
  95.                 WorkingItem.SubItems(3) = Format(InstanceFile.FileDate, "General Date")
  96.             End If
  97.         End If
  98.     Next
  99.     
  100. Cleanup:
  101.     Set InstanceFile = Nothing
  102.     Set TheseItems = Nothing
  103.     Set TheseNodes = Nothing
  104.     Set WorkingItem = Nothing
  105.     Set WorkingNode = Nothing
  106.  
  107.     ThisExplorer.MousePointer = vbDefault
  108.     
  109.     On Error GoTo 0
  110.     Exit Function
  111.     
  112. BadFile:
  113.     GoTo Cleanup
  114.     
  115. End Function
  116.  
  117.